package com.lm.picocli.subcommands;

import picocli.CommandLine;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.Callable;

@CommandLine.Command(name = "count", description = "统计文件行数")
class FileCountCommand implements Callable<Integer> {
    @CommandLine.Option(names = {"-p", "--path"}, description = "文件路径", required = true)
    private String filePath;

    @Override
    public Integer call() throws Exception {
        long lineCount = Files.lines(Paths.get(filePath)).count();
        System.out.println("文件行数: " + lineCount);
        return 0;
    }
}
